
/**
 * @file bitio.h
 * Bitwise file writer header
 */

#ifndef BITIO_H
#define BITIO_H

#include "common.h"

typedef struct BitWriter {
    uint32_t bit_buf;
    int bit_left;
    uint8_t *buffer, *buf_ptr, *buf_end;
    int eof;
} BitWriter;

void bitwriter_init(BitWriter *bw, void *buf, int len);

void bitwriter_flushbits(BitWriter *bw);

void bitwriter_writebits(BitWriter *bw, int bits, uint32_t val);

void bitwriter_writebit(BitWriter *bw, uint8_t val);

uint32_t bitwriter_bitcount(BitWriter *bw);

#endif /* BITIO_H */
